import { Injectable } from '@angular/core';
import {InterfaceProvider} from "@providers/interface";
import {PagingProvider} from "@providers/paging";

/*
  Generated class for the ProductProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class ProductProvider {

  constructor(private ifp: InterfaceProvider,
              private paging: PagingProvider,) {
  }

  /**
   * 新物料申请
   * @param item
   */
  seaveNewProduct(item): Promise<any> {
    return this.ifp.post({
      interfaceId: "csm.css.qcfwdef.insertSFSQXSP",
      data: item || {}
    }).toPromise()
  }

  /**
   * 新物料申请状态查询
   * @param item
   * @param pagingConfig 分页配置
   */
  getNewProductApplicationStatus(item, pagingConfig): Promise<any> {
    return this.paging.get({
      interfaceId: "csm.css.jcdy.qcfwquery.selectCXSQSPXX",
      data: item || {}
    }, pagingConfig).toPromise()
  }

  /**
   * 获取品牌
   * @param item
   * * @returns {Promise<any>}
   */
  getBrands(item): Promise<any> {
    return this.ifp.post({
      interfaceId: "csm.css.jcdy.qcfwdef.productBrand.select",
      data: item || {},
    }).toPromise()
  }/**
   * 获取类型
   * @param item
   * * @returns {Promise<any>}
   */
  getCategorys(item): Promise<any> {
    return this.ifp.post({
      interfaceId: "csm.css.jcdy.qcfwdef.productfl.query",
      data: item || {},
    }).toPromise()
  }

}
